Fedora 11
Sponsored Link

Virtual Hostings
  This is the example to configure virtual hostings.

Main host www1.srv.world [ /var/www/html ]
Virtual host www1.virtual.host [ /home/fedora/public_html ]

Add virtual domain name in DNS first.

[1] Configure httpd for virtual hostings
[root@www1 ~]#
vi /etc/httpd/conf/httpd.conf


# line 975: uncomment

NameVirtualHost *:80

# bottom: add these lines

<VirtualHost *:80>
   DocumentRoot /var/www/html
   ServerName www1.srv.world
   ErrorLog logs/srv.world-error_log
   CustomLog logs/srv.world-access_log common
</VirtualHost>


# bottom: add these lines

<VirtualHost *:80>
   DocumentRoot /home/fedora/public_html
   ServerName www1.virtual.host
   ErrorLog logs/virtual.host-error_log
   CustomLog logs/virtual.host-access_log common
</VirtualHost>


[root@www ~]#
/etc/rc.d/init.d/httpd restart

Stopping httpd:
[  OK  ]

Starting httpd:
[  OK  ]

[2] Access to the test page with original domain. It's OK if following page is shown.
 
[3] Create a test page for new domain. It's OK if following page is shown.
[root@www1 ~]#
cd /home/fedora/public_html

[root@www1 public_html]#
vi index.html


<html>
<body>
<div style="width:100%;font-size:40px;font-weight:bold;text-align:center">
Virtual Host Test Page
</div>
</body>
</html>
 
Tweet